"use strict";

/*
 * MikoPBX - free phone system for small business
 * Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program.
 * If not, see <https://www.gnu.org/licenses/>.
 */

/* global globalRootUrl, ivrActions, globalTranslate, Form, Extensions, SoundFilesSelector */
var ivrMenu = {
  /**
   * jQuery object for the form.
   * @type {jQuery}
   */
  $formObj: $('#ivr-menu-form'),
  $dropDowns: $('#ivr-menu-form .ui.dropdown'),
  $number: $('#extension'),
  $errorMessages: $('#form-error-messages'),
  $rowTemplate: $('#row-template'),
  defaultExtension: '',
  actionsRowsCount: 0,

  /**
   * Validation rules for the form fields before submission.
   *
   * @type {object}
   */
  validateRules: {
    name: {
      identifier: 'name',
      rules: [{
        type: 'empty',
        prompt: globalTranslate.iv_ValidateNameIsEmpty
      }]
    },
    extension: {
      identifier: 'extension',
      rules: [{
        type: 'empty',
        prompt: globalTranslate.iv_ValidateExtensionIsEmpty
      }, {
        type: 'existRule',
        prompt: globalTranslate.iv_ValidateExtensionIsDouble
      }]
    },
    timeout_extension: {
      identifier: 'timeout_extension',
      rules: [{
        type: 'empty',
        prompt: globalTranslate.iv_ValidateTimeoutExtensionIsEmpty
      }]
    },
    audio_message_id: {
      identifier: 'audio_message_id',
      rules: [{
        type: 'empty',
        prompt: globalTranslate.iv_ValidateAudioFileIsEmpty
      }]
    },
    timeout: {
      identifier: 'timeout',
      rules: [{
        type: 'integer[0..99]',
        prompt: globalTranslate.iv_ValidateTimeoutOutOfRange
      }]
    },
    number_of_repeat: {
      identifier: 'number_of_repeat',
      rules: [{
        type: 'integer[0..99]',
        prompt: globalTranslate.iv_ValidateRepeatNumberOutOfRange
      }]
    }
  },
  initialize: function initialize() {
    // Initialize dropdowns
    ivrMenu.$dropDowns.dropdown(); // Dynamic check to see if the selected number is available

    ivrMenu.$number.on('change', function () {
      var newNumber = ivrMenu.$formObj.form('get value', 'extension');
      Extensions.checkAvailability(ivrMenu.defaultNumber, newNumber);
    }); // Add event listener for adding a new IVR action row

    $('#add-new-ivr-action').on('click', function (el) {
      ivrMenu.addNewActionRow();
      ivrMenu.rebuildActionExtensionsDropdown(); // Trigger change event to acknowledge the modification

      Form.dataChanged();
      el.preventDefault();
    }); // Initialize audio message dropdowns

    $('#ivr-menu-form .audio-message-select').dropdown(SoundFilesSelector.getDropdownSettingsWithEmpty()); // Initialize the form

    ivrMenu.initializeForm(); // Build IVR menu actions

    ivrMenu.buildIvrMenuActions(); // Get the default extension value

    ivrMenu.defaultExtension = ivrMenu.$formObj.form('get value', 'extension');
  },

  /**
   * Create ivr menu items on the form
   */
  buildIvrMenuActions: function buildIvrMenuActions() {
    var objActions = JSON.parse(ivrActions);
    objActions.forEach(function (element) {
      ivrMenu.addNewActionRow(element);
    });
    if (objActions.length === 0) ivrMenu.addNewActionRow();
    ivrMenu.rebuildActionExtensionsDropdown();
  },

  /**
   * Adds new form validation rules for a newly added action row.
   * @param {string} newRowId - The ID of the newly added action row.
   */
  addNewFormRules: function addNewFormRules(newRowId) {
    // Create the identifier for the digits field of the new row
    var $digitsClass = "digits-".concat(newRowId); // Define the validation rules for the digits field

    ivrMenu.validateRules[$digitsClass] = {
      identifier: $digitsClass,
      rules: [{
        type: 'regExp[/^[0-9]{1,7}$/]',
        prompt: globalTranslate.iv_ValidateDigitsIsNotCorrect
      }, {
        type: 'checkDoublesDigits',
        prompt: globalTranslate.iv_ValidateDigitsIsNotCorrect
      }]
    }; // Create the identifier for the extension field of the new row

    var $extensionClass = "extension-".concat(newRowId); // Define the validation rules for the extension field

    ivrMenu.validateRules[$extensionClass] = {
      identifier: $extensionClass,
      rules: [{
        type: 'empty',
        prompt: globalTranslate.iv_ValidateExtensionIsNotCorrect
      }]
    };
  },

  /**
   * Adds a new action row to the IVR menu form.
   * @param {Object} paramObj - Optional parameter object with initial values for the action row.
   *                            If not provided, default values will be used.
   */
  addNewActionRow: function addNewActionRow(paramObj) {
    // Default parameter values
    var param = {
      id: '',
      extension: '',
      extensionRepresent: '',
      digits: ''
    }; // Override default values with the provided parameter object

    if (paramObj !== undefined) {
      param = paramObj;
    } // Increment the actionsRowsCount


    ivrMenu.actionsRowsCount += 1; // Clone the row template and modify its attributes and content

    var $actionTemplate = ivrMenu.$rowTemplate.clone();
    $actionTemplate.removeClass('hidden').attr('id', "row-".concat(ivrMenu.actionsRowsCount)).attr('data-value', ivrMenu.actionsRowsCount).attr('style', ''); // Set the attributes and values for digits input field

    $actionTemplate.find('input[name="digits-id"]').attr('id', "digits-".concat(ivrMenu.actionsRowsCount)).attr('name', "digits-".concat(ivrMenu.actionsRowsCount)).attr('value', param.digits); // Set the attributes and values for extension input field

    $actionTemplate.find('input[name="extension-id"]').attr('id', "extension-".concat(ivrMenu.actionsRowsCount)).attr('name', "extension-".concat(ivrMenu.actionsRowsCount)).attr('value', param.extension); // Set the data-value attribute for the delete-action-row element

    $actionTemplate.find('div.delete-action-row').attr('data-value', ivrMenu.actionsRowsCount); // Update the extensionRepresent content based on the provided value or default text

    if (param.extensionRepresent.length > 0) {
      $actionTemplate.find('div.default.text').removeClass('default').html(param.extensionRepresent);
    } else {
      $actionTemplate.find('div.default.text').html(globalTranslate.ex_SelectNumber);
    } // Append the action template to the actions-place element


    $('#actions-place').append($actionTemplate); // Add new form rules for the newly added action row

    ivrMenu.addNewFormRules(ivrMenu.actionsRowsCount);
  },

  /**
   * Rebuilds the action extensions dropdown by initializing the dropdown settings for routing
   * and attaching the cbOnExtensionSelect callback function to handle the extension selection event.
   */
  rebuildActionExtensionsDropdown: function rebuildActionExtensionsDropdown() {
    // Initialize the dropdown settings for routing with cbOnExtensionSelect callback function
    $('#ivr-menu-form .forwarding-select').dropdown(Extensions.getDropdownSettingsForRouting(ivrMenu.cbOnExtensionSelect)); // Attach a click event handler to the delete-action-row elements

    $('.delete-action-row').on('click', function (e) {
      e.preventDefault(); // Get the 'data-value' attribute of the clicked element

      var id = $(this).attr('data-value'); // Remove the corresponding rules from validateRules object

      delete ivrMenu.validateRules["digits-".concat(id)];
      delete ivrMenu.validateRules["extension-".concat(id)]; // Remove the row with the corresponding id

      $("#row-".concat(id)).remove(); // Trigger change event to acknowledge the modification

      Form.dataChanged();
    });
  },

  /**
   * Callback function to be called before the form is sent
   * @param {Object} settings - The current settings of the form
   * @returns {Object} - The updated settings of the form
   */
  cbBeforeSendForm: function cbBeforeSendForm(settings) {
    // Copy the settings object to a new variable to avoid modifying the original
    var result = settings; // Get the form values from $formObj of ivrMenu

    result.data = ivrMenu.$formObj.form('get values'); // Initialize an array to store actions

    var arrActions = []; // Iterate over each action row

    $('.action-row').each(function (index, obj) {
      var rowId = $(obj).attr('data-value'); // If rowId is greater than 0, get the 'digits' and 'extension' values from the form and push them into the arrActions array

      if (rowId > 0) {
        arrActions.push({
          digits: ivrMenu.$formObj.form('get value', "digits-".concat(rowId)),
          extension: ivrMenu.$formObj.form('get value', "extension-".concat(rowId))
        });
      }
    }); // If there are no action rows, set the result to false, display an error message and add error class to the form

    if (arrActions.length === 0) {
      result = false;
      ivrMenu.$errorMessages.html(globalTranslate.iv_ValidateNoIVRExtensions);
      ivrMenu.$formObj.addClass('error');
    } else {
      // Convert the arrActions array into a JSON string and assign it to 'actions' key in the result data object
      result.data.actions = JSON.stringify(arrActions);
    } // Return the modified settings object or false


    return result;
  },

  /**
   * Callback function that triggers when a number is selected from the dropdown menu.
   * It generates a random number and triggers a change event.
   */
  cbOnExtensionSelect: function cbOnExtensionSelect() {
    // Trigger change event to acknowledge the modification
    Form.dataChanged();
  },

  /**
   * Callback function to be called after the form has been sent.
   * @param {Object} response - The response from the server after the form is sent
   */
  cbAfterSendForm: function cbAfterSendForm(response) {},

  /**
   * Initialize the form with custom settings
   */
  initializeForm: function initializeForm() {
    Form.$formObj = ivrMenu.$formObj;
    Form.url = "".concat(globalRootUrl, "ivr-menu/save"); // Form submission URL

    Form.validateRules = ivrMenu.validateRules; // Form validation rules

    Form.cbBeforeSendForm = ivrMenu.cbBeforeSendForm; // Callback before form is sent

    Form.cbAfterSendForm = ivrMenu.cbAfterSendForm; // Callback after form is sent

    Form.initialize();
  }
};
/**
 * Custom form rule to check if an element with id 'extension-error' has the class 'hidden'.
 */

$.fn.form.settings.rules.existRule = function () {
  return $('#extension-error').hasClass('hidden');
};
/**
 * Custom form rule to check for duplicate digits values.
 * @param {string} value - The value to check for duplicates.
 * @returns {boolean} - True if there are no duplicates, false otherwise.
 */


$.fn.form.settings.rules.checkDoublesDigits = function (value) {
  var count = 0;
  $("input[id^='digits']").each(function (index, obj) {
    if (ivrMenu.$formObj.form('get value', "".concat(obj.id)) === value) count += 1;
  });
  return count === 1;
};
/**
 *  Initialize IVR menu modify form on document ready
 */


$(document).ready(function () {
  ivrMenu.initialize();
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9JdnJNZW51L2l2cm1lbnUtbW9kaWZ5LmpzIl0sIm5hbWVzIjpbIml2ck1lbnUiLCIkZm9ybU9iaiIsIiQiLCIkZHJvcERvd25zIiwiJG51bWJlciIsIiRlcnJvck1lc3NhZ2VzIiwiJHJvd1RlbXBsYXRlIiwiZGVmYXVsdEV4dGVuc2lvbiIsImFjdGlvbnNSb3dzQ291bnQiLCJ2YWxpZGF0ZVJ1bGVzIiwibmFtZSIsImlkZW50aWZpZXIiLCJydWxlcyIsInR5cGUiLCJwcm9tcHQiLCJnbG9iYWxUcmFuc2xhdGUiLCJpdl9WYWxpZGF0ZU5hbWVJc0VtcHR5IiwiZXh0ZW5zaW9uIiwiaXZfVmFsaWRhdGVFeHRlbnNpb25Jc0VtcHR5IiwiaXZfV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3JNZXNzYWdlczogJCgnI2Zvcm0tZXJyb3ItbWVzc2FnZXMnKSxcbiAgICAkcm93VGVtcGxhdGU6ICQoJyNyb3ctdGVtcGxhdGUnKSxcbiAgICBkZWZhdWx0RXh0ZW5zaW9uOiAnJyxcbiAgICBhY3Rpb25zUm93c0NvdW50OiAwLFxuXG4gICAgLyoqXG4gICAgICogVmFsaWRhdGlvbiBydWxlcyBmb3IgdGhlIGZvcm0gZmllbGRzIGJlZm9yZSBzdWJtaXNzaW9uLlxuICAgICAqXG4gICAgICogQHR5cGUge29iamVjdH1cbiAgICAgKi9cbiAgICB2YWxpZGF0ZVJ1bGVzOiB7XG4gICAgICAgIG5hbWU6IHtcbiAgICAgICAgICAgIGlkZW50aWZpZXI6ICduYW1lJyxcbiAgICAgICAgICAgIHJ1bGVzOiBbXG4gICAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiAnZW1wdHknLFxuICAgICAgICAgICAgICAgICAgICBwcm9tcHQ6IGdsb2JhbFRyYW5zbGF0ZS5pdl9WYWxpZGF0ZU5hbWVJc0VtcHR5LFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBdLFxuICAgICAgICB9LFxuICAgICAgICBleHRlbnNpb246IHtcbiAgICAgICAgICAgIGlkZW50aWZpZXI6ICdleHRlbnNpb24nLFxuICAgICAgICAgICAgcnVsZXM6IFtcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6ICdlbXB0eScsXG4gICAgICAgICAgICAgICAgICAgIHByb21wdDogZ2xvYmFsVHJhbnNsYXRlLml2X1ZhbGlkYXRlRXh0ZW5zaW9uSXNFbXB0eSxcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogJ2V4aXN0UnVsZScsXG4gICAgICAgICAgICAgICAgICAgIHByb21wdDogZ2xvYmFsVHJhbnNsYXRlLml2X1ZhbGlkYXRlRXh0ZW5zaW9uSXNEb3VibGUsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIF0sXG4gICAgICAgIH0sXG4gICAgICAgIHRpbWVvdXRfZXh0ZW5zaW9uOiB7XG4gICAgICAgICAgICBpZGVudGlmaWVyOiAndGltZW91dF9leHRlbnNpb24nLFxuICAgICAgICAgICAgcnVsZXM6IFtcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6ICdlbXB0eScsXG4gICAgICAgICAgICAgICAgICAgIHByb21wdDogZ2xvYmFsVHJhbnNsYXRlLml2X1ZhbGlkYXRlVGltZW91dEV4dGVuc2lvbklzRW1wdHksXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIF0sXG4gICAgICAgIH0sXG4gICAgICAgIGF1ZGlvX21lc3NhZ2VfaWQ6IHtcbiAgICAgICAgICAgIGlkZW50aWZpZXI6ICdhdWRpb19tZXNzYWdlX2lkJyxcbiAgICAgICAgICAgIHJ1bGVzOiBbXG4gICAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiAnZW1wdHknLFxuICAgICAgICAgICAgICAgICAgICBwcm9tcHQ6IGdsb2JhbFRyYW5zbGF0ZS5pdl9WYWxpZGF0ZUF1ZGlvRmlsZUlzRW1wdHksXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIF0sXG4gICAgICAgIH0sXG4gICAgICAgIHRpbWVvdXQ6IHtcbiAgICAgICAgICAgIGlkZW50aWZpZXI6ICd0aW1lb3V0JyxcbiAgICAgICAgICAgIHJ1bGVzOiBbXG4gICAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgICAgICB0eXBlOiAnaW50ZWdlclswLi45OV0nLFxuICAgICAgICAgICAgICAgICAgICBwcm9tcHQ6IGdsb2JhbFRyYW5zbGF0ZS5pdl9WYWxpZGF0ZVRpbWVvdXRPdXRPZlJhbmdlLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBdLFxuICAgICAgICB9LFxuICAgICAgICBudW1iZXJfb2ZfcmVwZWF0OiB7XG4gICAgICAgICAgICBpZGVudGlmaWVyOiAnbnVtYmVyX29mX3JlcGVhdCcsXG4gICAgICAgICAgICBydWxlczogW1xuICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogJ2ludGVnZXJbMC4uOTldJyxcbiAgICAgICAgICAgICAgICAgICAgcHJvbXB0OiBnbG9iYWxUcmFuc2xhdGUuaXZfVmFsaWRhdGVSZXBlYXROdW1iZXJPdXRPZlJhbmdlLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBdLFxuICAgICAgICB9LFxuICAgIH0sXG5cbiAgICBpbml0aWFsaXplKCkge1xuICAgICAgICAvLyBJbml0aWFsaXplIGRyb3Bkb3duc1xuICAgICAgICBpdnJNZW51LiRkcm9wRG93bnMuZHJvcGRvd24oKTtcblxuICAgICAgICAvLyBEeW5hbWljIGNoZWNrIHRvIHNlZSBpZiB0aGUgc2VsZWN0ZWQgbnVtYmVyIGlzIGF2YWlsYWJsZVxuICAgICAgICBpdnJNZW51LiRudW1iZXIub24oJ2NoYW5nZScsICgpID0+IHtcbiAgICAgICAgICAgIGNvbnN0IG5ld051bWJlciA9IGl2ck1lbnUuJGZvcm1PYmouZm9ybSgnZ2V0IHZhbHVlJywgJ2V4dGVuc2lvbicpO1xuICAgICAgICAgICAgRXh0ZW5zaW9ucy5jaGVja0F2YWlsYWJpbGl0eShpdnJNZW51LmRlZmF1bHROdW1iZXIsIG5ld051bWJlcik7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIC8vIEFkZCBldmVudCBsaXN0ZW5lciBmb3IgYWRkaW5nIGEgbmV3IElWUiBhY3Rpb24gcm93XG4gICAgICAgICQoJyNhZGQtbmV3LWl2ci1hY3Rpb24nKS5vbignY2xpY2snLCAoZWwpID0+IHtcbiAgICAgICAgICAgIGl2ck1lbnUuYWRkTmV3QWN0aW9uU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saWRhdGVEaWdpdHNJc05vdENvcnJlY3QsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGU6ICdjaGVja0RvdWJsZXNEaWdpdHMnLFxuICAgICAgICAgICAgICAgICAgICBwcm9tcHQ6IGdsb2JhbFRyYW5zbGF0ZS5pdl9WYWxpZGF0ZURpZ2l0c0lzTm90Q29ycmVjdCxcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgXSxcblxuICAgICAgICB9O1xuXG4gICAgICAgIC8vIENyZWF0ZSB0aGUgaWRlbnRpZmllciBmb3IgdGhlIGV4dGVuc2lvbiBmaWVsZCBvZiB0aGUgbmV3IHJvd1xuICAgICAgICBjb25zdCAkZXh0ZW5zaW9uQ2xhc3MgPSBgZXh0ZW5zaW9uLSR7bmV3Um93SWR9YDtcblxuICAgICAgICAvLyBEZWZpbmUgdGhlIHZhbGlkYXRpb24gcnVsZXMgZm9yIHRoZSBleHRlbnNpb24gZmllbGRcbiAgICAgICAgaXZyTWVudS52YWxpZGF0ZVJ1bGVzWyRleHRlbnNpb25DbGFzc10gPSB7XG4gICAgICAgICAgICBpZGVudGlmaWVyOiAkZXh0ZW5zaW9uQ2xhc3MsXG4gICAgICAgICAgICBydWxlczogW1xuICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZTogJ2VtcHR5JyxcbiAgICAgICAgICAgICAgICAgICAgcHJvbXB0OiBnbG9iYWxUcmFuc2xhdGUuaXZfVmFsaWRhdGVFeHRlbnNpb25Jc05vdENvcnJlY3QsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIF0sXG5cbiAgICAgICAgfTtcbiAgICB9LFxuXG4gICAgLyoqXG4gICAgICogQWRkcyBhIG5ldyBhY3Rpb24gcm93IHRvIHRoZSBJVlIgbWVudSBmb3JtLlxuICAgICAqIEBwYXJhbSB7T2JqZWN0fSBwYXJhbU9iaiAtIE9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